package com.qf.mybatisDemo_RandomPickName.until;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author 刘欣
 * @createTime 2022/12/21 14:10
 * @description
 */
public class CreateSqlSession {
    public static SqlSession getSession() throws IOException {
        final InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
        final SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
        return sqlSessionFactory.openSession();
    }
}
